package org.vectrics.recruiter.struts.admin;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Category;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.vectrics.recruiter.RecruitServiceLocator;
import org.vectrics.recruiter.job.Job;

public class RefreshJobPostDateAction extends Action {
    
	private static Category log = Category.getInstance(RefreshJobPostDateAction.class);
    public static String ACTION_NAME = "rmv_job";
    public static String JOB_PARAM = "job";    
    private boolean newJob = false;
    
    public RefreshJobPostDateAction() {
    }

	public ActionForward execute(ActionMapping mapping,
				 ActionForm form,
				 HttpServletRequest request,
				 HttpServletResponse response)	throws Exception {
				 	
        log.debug("execute() called");
        String jobIdParam = request.getParameter("jobId");
        Long jobId = new Long(jobIdParam);
 
        try {
        	Job job = RecruitServiceLocator.getJobProvider().findJob(jobId); 
            RecruitServiceLocator.getJobProvider().resetJobPostDate(job);
        }
        catch (Exception re) {
            log.error("execute() - exception refreshing date posted on job: " + jobId, re);
        }
        
		return (mapping.findForward("success"));
        
    }

}
